package com.zy.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zy.Vo.HousedVo;
import com.zy.Vo.OutboundVo;
import com.zy.Vo.PageHousedVO;
import com.zy.Vo.PageOutboundVO;
import com.zy.mapper.OutboundMapper;
import com.zy.pojo.Housed;
import com.zy.pojo.Outbound;
import com.zy.service.OutboundService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service("outboundService")
public class OutboundServiceImpl implements OutboundService {
    @Resource
    private OutboundMapper outboundMapper;


    @Override
    public PageOutboundVO getPageOutboundList(Integer pageSize, Integer pageNo, OutboundVo outboundVo) {
        Page page = new Page();
        page.setSize(pageSize);
        page.setCurrent(pageNo);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.like(!StringUtils.isEmpty(outboundVo.getName()),"name",outboundVo.getName())
                .like(outboundVo.getPoId()!=null,"po_id",outboundVo.getPoId())
                .eq(outboundVo.getQuantity()!=null,"quantity",outboundVo.getQuantity())
                .gt(outboundVo.getOutboundDateg()!=null,"outbound_date",outboundVo.getOutboundDateg())
                .lt(outboundVo.getOutboundDatel()!=null,"outbound_date",outboundVo.getOutboundDatel());
        List<Outbound> list = outboundMapper.getInboundPageList(page,queryWrapper);
        System.out.println(page.getTotal()+"+++++++++++");
        return new PageOutboundVO(list,page.getTotal());
    }

    @Override
    public void getOutboundAdd(Outbound outbound) {
        outboundMapper.insert(outbound);
    }

    @Override
    public void getOutboundDelete(Integer id) {
        outboundMapper.deleteById(id);
    }

    @Override
    public void getOutboundGoodsAdd(Outbound outbound) {
        outboundMapper.getOutboundGoodsAdd(outbound);
    }
}
